package com.antony.PlaneBattle0915;

import java.awt.Graphics;
import java.awt.Image;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class ShowThread extends Thread {
	private Graphics g;
	private Image BackGround = new ImageIcon(this.getClass().getResource("BackGround.jpg")).getImage();
	private JFrame jsf;
	private boolean start = true;
	private boolean pause = true;
	private ArrayList<StoreThings> things;
	
	public ShowThread(Graphics g, JFrame jsf, ArrayList<StoreThings> things) {
		this.g = g;
		this.jsf = jsf;
		this.things = things;
	}
	
	public void setStart(boolean start){
		this.start = start;
	}
	
	public void setPause(boolean pause){
		this.pause =pause;
	}

	public void run() {
		while (start) {
			if (pause) {
				System.out.println("<<<<"+jsf);
				g.drawImage(BackGround, 100, 0, jsf.getWidth(), jsf.getHeight(), jsf);
				for (int i = 0; i < things.size(); i++) {
					StoreThings temp = things.get(i);
					temp.showThings();
				}
				try {
					Thread.sleep(200);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}
